package com.woniuxy.oldmanapi.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.oldmanapi.entity.OlderHeight;
import com.woniuxy.oldmanapi.mapper.OlderHeightMapper;
import com.woniuxy.oldmanapi.vo.HeightVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HeightService {

    @Autowired
    OlderHeightMapper olderHeightMapper ;

    public PageInfo<HeightVo> findHeightByPage(Integer now, Integer size, String name) {
        PageHelper.startPage(now,size);
        List<HeightVo> HeightVoList =  olderHeightMapper.selectHeightByName(name);
        return new PageInfo<>(HeightVoList);
    }

    public void add(OlderHeight olderHeight) {
        olderHeightMapper.insert(olderHeight);
    }

    public void delete(int id) {
        olderHeightMapper.deleteByPrimaryKey(id);
    }

    public void modify(OlderHeight olderHeight) {
        olderHeightMapper.updateByPrimaryKey(olderHeight);
    }

    public HeightVo selectOne(int id) {
        return olderHeightMapper.selectOneByName(id);
    }
}
